<template>
  <div class="page-container hide-scrollbar">
    <div class="special-topic" v-for="item in specialTopicdata" :key="item.id"
      :style="`background-image: url(${item.cover})`" @click="handleTopicClick">
      <span>#专题</span>
      <div class="special-topic-bottom">{{ item.title }}</div>
    </div>

    <div v-if="specialTopicdata.length == 0" class="loading">加载中...</div>

  </div>
</template>

<script>
import { getTopicBanner } from '@/api/api'
export default {
  data() {
    return {
      specialTopicdata: []
    }
  },
  methods: {
    handleTopicClick() {
      this.$toast({
        message: '暂时没有数据',
        position: 'bottom'
      });
    }
  },
  created() {
    getTopicBanner()
      .then(res => {
        // console.log(res.data);
        this.specialTopicdata = res.data
      })
  }
}
</script>

<style scoped lang="less">
.page-container {
  width: 100vw;
  min-height: 100vh;
  padding: 10vh 10px 7vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
  gap: 5vh;
  background-color: #fff;
  overflow-x: hidden;

  .special-topic {
    width: 100%;
    height: 22vh;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    box-shadow: 2px 2px 4px #0000001a;

    span {
      position: absolute;
      bottom: 5vh;
      left: 2vw;
      color: #ccc;
      font-size: 8px;
    }

    .special-topic-bottom {
      position: absolute;
      bottom: 0;
      left: 0;
      width: 100%;
      height: 4vh;
      background-color: #f8f8f8;
      font-size: 11px;
      padding-left: 10px;
      box-sizing: border-box;
      border-bottom-left-radius: 8px;
      border-bottom-right-radius: 8px;
      display: flex;
      align-items: center;
    }
  }
}

.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;

  &::-webkit-scrollbar {
    display: none;
  }
}

.loading {
  width: 100%;
  text-align: center;
  padding: 20px;
  font-size: 14px;
  color: #999;
}
</style>